package cn.ds.assets.module.app.utils;

import lombok.extern.slf4j.Slf4j;

import java.util.Random;

/**
 * 系统生成编码工具类
 *
 * @author yxc
 * @desc:
 * @date 2023-2023/6/29-29 11:37:53
 */
@Slf4j
public class GenerateCodeUtils {

    private final static String[] BASE_CODE = {"0", "1", "2","3","4","5","6","7","8","9"};

    private static Random random = new Random();

    private GenerateCodeUtils() {
    }

    public static String getBusinessCode(String codeSuffix, int size) {
        int index;
        int length = BASE_CODE.length;
        StringBuilder builder = new StringBuilder(codeSuffix);
        for (int i = 0; i < size; i++) {
            index = random.nextInt(length);
            builder.append(BASE_CODE[index]);
        }
        return builder.toString();
    }

}
